package com.hzhr.iot.cqgas.ds.service;

import com.hzhr.iot.cqgas.ds.dao.statis.example.StatisOptionsDao;
import com.hzhr.iot.cqgas.ds.entity.statis.StatisOptionsEntity;
import com.hzhr.iot.cqgas.ds.entity.statis.StatisOptionsExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StatisOptionsService {
    @Autowired
    StatisOptionsDao statisOptionsDao;

    public String getCode(String typeName, String name) {
        StatisOptionsExample statisOptionsExample = new StatisOptionsExample();
        statisOptionsExample.createCriteria()
                .andTypeNameEqualTo(typeName)
                .andNameEqualTo(name);
        List<StatisOptionsEntity> statisOptionsEntities = statisOptionsDao.selectByExample(statisOptionsExample);
        if (statisOptionsEntities.size() == 0) return null;
        return statisOptionsEntities.get(0).getCode();
    }
}
